<?php

use yii\db\Migration;

/**
 * Class m200614_073218_seckill_goods
 */
class m200614_073218_seckill_goods extends Migration
{
	public $tableName = '{{%goods}}';
	/**
	 * {@inheritdoc}
	 */
	public function safeUp()
	{
		$tableOptions = null;
		if ($this->db->getDriverName() === 'mysql') {
			$tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB COMMENT="商品表" ';
		}
		$this->createTable($this->tableName, [
			'id' => $this->primaryKey()->comment('唯一键'),//默认自动增长AUTO_INCREMENT
			'name'=>$this->string()->notNull()->comment('商品名称'),
			'bn'=>$this->integer(11)->notNull()->comment('商品编码'),
			'stock'=>$this->integer(11)->notNull()->comment('库存'),
			'version'=>$this->integer(11)->notNull()->comment('版本号'),
			'create_time' => $this->integer(11)->comment('创建时间'),
			'update_time' => $this->integer(11)->comment('更新时间'),
			'status' => $this->tinyInteger(1)->defaultValue(1)->comment('状态：1、正常，2、失效'),
		], $tableOptions);
		$this->createIndex('idx_bn',$this->tableName,'bn');
	}

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        echo "m200614_073218_seckill_goods cannot be reverted.\n";

        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m200614_073218_seckill_goods cannot be reverted.\n";

        return false;
    }
    */
}
